<%@ page contentType="text/html; charset=utf-8" %>
	//如果内容有修改，则先提示是否关闭
	function closeWin(){
		var newValue=$('fcoworker').serialize();
		if(sourceValue==newValue){
			windowClose();
		}else{
			AskConfirmTwo('${key.tipsForCloseWindow}',"editCoworkerFrame","afterCloseDo","windowClose");
		}
	}

	//关闭窗口前执行的动作
	function afterCloseDo(){
		if(${isEdit}){
			editCoWorker();
		}else{
			addCoWorker();
		}
	}

	//增加操作,参数为响应结果的方法
	function addCoWorker(){
		var url= ACTION_URL + "method=addCoWorker";
		var pars=$('fcoworker').serialize();
		//校验
		var isTure=$("fcoworker").fireEvent("onSubmit")
		//ajax提交
		if(isTure){
			closeORopenButton();
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: showResponseAdd}
		                    );
		}
	}

	//增加操作的响应
	function showResponseAdd(result){
		var obj=findFrame('main');
		obj.reLoadIFrameList();
		closeORopenButton();
		ajaxSubmitException(result.responseText);
		windowClose();
	}

	//修改
	function editCoWorker(){
		var url= ACTION_URL + "method=editCoWorker";
		var pars=$('fcoworker').serialize();
		//校验
		var isTure= $("fcoworker").fireEvent("onSubmit");
		//ajax提交
		if(isTure){
			closeORopenButton();
//			alert(url);
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: showResponseEdit}
		                    );
		}
	}

	//修改操作的响应
	function showResponseEdit(result){
		var obj=findFrame('main');
		obj.reLoadIFrameListWithQuery();
		closeORopenButton();
		ajaxSubmitException(result.responseText);
		windowClose();
	}


	//关闭或打开按钮事件
	function closeORopenButton(){
		$('window_footer').disabled= !$('window_footer').disabled;
		$('btn1_22').disabled= !$('btn1_22').disabled;
		$('btn1_32').disabled= !$('btn1_32').disabled;
	}

	//初始化
	function init(){
		$('name').focus();
		sourceValue=$('fcoworker').serialize();
		if(${isEdit}){
			$('head_title').innerText='${key.modify}';
			Event.observe('btn1_22','click',editCoWorker);
		}else{
			$('head_title').innerText='${key.add}';
			Event.observe('btn1_22','click',addCoWorker);
		}
		$('name').validateUrl= ACTION_URL + "method=checkCoworkByID";
	}

